#!/usr/bin/env bash
#########################################################################
# File Name   : nova.sh.j2
# Author      : seadog
# mail        : seadog0514@163.com
# Version     : 0.1
# Created Time: Mon 2024-09-30 13:17:38(+0800)
#########################################################################

#
#
# Usage:

{
  set -euo pipefail
  # set -E
  #     If set, any trap on ERR is inherited by shell functions, command
  #     substitutions, and commands executed in a subshell environment.

}

source /root/keystonerc

openstack --insecure user create --domain default --project service --password {{ service_password }} glance

# add [glance] user in [admin] role
openstack --insecure role add --project service --user glance admin
# create service entry for [glance]
openstack --insecure service create --name glance --description "OpenStack Image service" image

# define Glance API Host
export controller={{ inventory_hostname }}
# create endpoint for [glance] (public)
openstack --insecure endpoint create --region RegionOne image public https://$controller:9292

# create endpoint for [glance] (internal)
openstack --insecure endpoint create --region RegionOne image internal https://$controller:9292

# create endpoint for [glance] (admin)
openstack --insecure endpoint create --region RegionOne image admin https://$controller:9292
